<template>
  <el-dialog title="数据导入" :visible="isShow" width="530px" @close="closeFn">
    <el-form ref="setForm">
      <el-form-item label="标题：" label-width="120px">
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="1"
          :on-exceed="handleExceed"
          :file-list="fileList"
        >
          <el-button
            type="primary"
            style="background-color: #5f84ff; width: 250px"
          >
            <i class="el-icon-upload2" /> 上传文件</el-button
          >
          <template #tip>
            <div style="color: #bac0cd">
              支持扩展名：xls、xlsx，文件不得大于1M
            </div>
          </template>
        </el-upload>
      </el-form-item>
      <el-row type="flex" justify="center">
        <el-col :span="10">
          <el-button
            class="btn cancel"
            @click="closeFn"
            style="margin-right: 20px"
            >取消</el-button
          >
          <el-button class="btn confirm" type="primary" @click="submit"
            >确认</el-button
          >
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
export default {
  props: {
    isShow: Boolean,
  },
  data() {
    return {
      fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}]
    };
  },
  methods: {  
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 1 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    closeFn() {
      this.$emit("update:isShow", false);
    },
    submit() {},
  },
};
</script>

<style lang="scss" scoped>
.btn {
  width: 80px;
  height: 36px;
  border: none;
  padding: 0;
  line-height: 36px;
}
.cancel {
  background-color: #fbf4f0;
  color: #7e7570;
}
.confirm {
  background-color: #ff6d29;
  color: #fff;
}
</style>
